package ve.co.bsc.appdescarga.domain;

import java.util.List;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.roo.addon.entity.RooEntity;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Set;
import ve.co.bsc.appdescarga.domain.Programa;
import java.util.HashSet;
import javax.persistence.CascadeType;

@Entity
@RooJavaBean
@RooToString
@RooEntity(finders = { "findUsuariosByCode", "findUsuariosByEmail" })
public class Usuario {

    @NotNull
    @Size(min = 4)
    private String nombre;

    @NotNull
    @Size(min = 4)
    private String telefono;

    @NotNull
    @Size(min = 4)
    private String email;

    @NotNull
    private String password;

    private String password2;

    private Boolean activo;

    @NotNull
    private String pais;

    private String code;

    @ManyToMany(targetEntity = RolUsuario.class)
    @JoinColumn
    private List<RolUsuario> roles;

    @ManyToMany(cascade = CascadeType.ALL)
    private Set<Programa> programas = new HashSet<Programa>();
}
